package org.huel.backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.huel.backend.domain.entity.User;

import java.util.List;

/**
 * @author Liweijian.
 * @Description TODO
 * @date 2024/11/28 14:38
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {


    /**
     * 根据学生ID查询用户
     * @param studentId 学生ID
     * @return 用户实体
     */
    @Select("SELECT * FROM user WHERE student_id = #{studentId}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "userName", column = "user_name"),
            @Result(property = "studentId", column = "student_id"),
            @Result(property = "password", column = "password"),
            @Result(property = "address", column = "address"),
            @Result(property = "classId", column = "class_id")
    })
    User selectByStudentId(@Param("studentId") String studentId);

    /**
     * 根据班级ID查询所有用户
     * @param classId 班级ID
     * @return 用户列表
     */
    @Select("SELECT * FROM user WHERE class_id = #{classId}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "userName", column = "user_name"),
            @Result(property = "studentId", column = "student_id"),
            @Result(property = "password", column = "password"),
            @Result(property = "address", column = "address"),
            @Result(property = "classId", column = "class_id")
    })
    List<User> selectByClassId(@Param("classId") String classId);


}
